//
//  Macros.h
//  mijifen_ios
//
//  Created by 朱凯 on 2017/10/9.
//  Copyright © 2017年 itboye. All rights reserved.
//

#ifndef Macros_h
#define Macros_h

// 接口地址定义 ————————————————————————————————
// client
#define BOYE_CLIENT_ID      @"by_ios_test_client_id"
#define BOYE_CLIENT_SECRET  @"byTestSecret654321"
// 基础apiURL
#define BOYE_BASE_URL       @"http://api.jinpu.8raw.com"
// H5页面地址
#define BOYE_WEB_BASE_URL               [NSString stringWithFormat:@"http://api.ewelisten.com/web.php/web/"]
// 图片地址
#define BOYE_IMAGE_URL_ORIGINAL(id)     [NSString stringWithFormat:@"%@/picture/index?id=%@", BOYE_API_URL, id]
#define BOYE_IMAGE_URL(id, size)        [NSString stringWithFormat:@"%@/picture/index?id=%@&size=%@", BOYE_API_URL, id, size]
// 图片地址
#define BOYE_PICTURE_VIEW_URL(id)       [NSString stringWithFormat:@"%@/picture/index?id=%@", BOYE_BASE_URL, id]
// 头像地址
#define BOYE_AVATAR_URL(uid)            [NSString stringWithFormat:@"%@/picture/avatar?uid=%@", BOYE_BASE_URL, uid]


// 系统相关宏 ————————————————————————————————————
// 打印
#ifdef DEBUG
#define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#define DLog(...)
#endif

// 判断版本号
#define SYSTEM_VERSION_EQUAL_TO(v)                  ([UIDevice currentDevice].systemVersion.doubleValue == v)
#define SYSTEM_VERSION_GREATER_THAN(v)              ([UIDevice currentDevice].systemVersion.doubleValue > v)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([UIDevice currentDevice].systemVersion.doubleValue >= v)
#define SYSTEM_VERSION_LESS_THAN(v)                 ([UIDevice currentDevice].systemVersion.doubleValue < v)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([UIDevice currentDevice].systemVersion.doubleValue <= v)

// 系统
#define APP_SCHEME              [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"]
#define APP_NAME                [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]
#define APP_SHORT_VERSION       [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]
#define APP_BUNDLE_VERSION      [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]
#define APP_VERSION             [NSString stringWithFormat:@"%@.%@", APP_SHORT_VERSION,APP_BUNDLE_VERSION]

// 常用宏 ————————————————————————————
// 宽高
#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)

// 颜色
#define BY_THEME_COLOR rgba(131, 216, 256, 1)
#define rgba(r, g, b, a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]
#define BY_TEXT_COLOR rgba(131, 216, 256, 1)
#define BY_TABLE_COLOR rgba(244, 245, 246, 1)
#define FONT(size) [UIFont systemFontOfSize:size]
#define B_FONT(size) [UIFont boldSystemFontOfSize:size]

// 默认图片
#define DEFAULT_IMAGE [UIImage imageNamed:@"Common_default_1_1"]
#define DEFAULT_IMAGE_1_2 [UIImage imageNamed:@"Common_default_1_1"]
#define DEFAULT_IMAGE_2_1 [UIImage imageNamed:@"Common_default_2_1"]


// ios11滑动视图适配
#define adjustsScrollViewInsets_NO(scrollView,vc)\
do { \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
if ([UIScrollView instancesRespondToSelector:NSSelectorFromString(@"setContentInsetAdjustmentBehavior:")]) {\
    [scrollView performSelector:NSSelectorFromString(@"setContentInsetAdjustmentBehavior:") withObject:@(2)];\
} else {\
    vc.automaticallyAdjustsScrollViewInsets = NO;\
}\
_Pragma("clang diagnostic pop") \
} while (0)

#endif /* Macros_h */
